ocaml/xenctrl: Fix stub_xc_readconsolering()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Jan 2015 14:11:14 +0000 (14:11 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 2 Feb 2015 14:45:36 +0000 (14:45 +0000)
commit1a010ca99e9b04c1cfbd0ee718aa22d5ebd530ab
tree7727d2d75aeec415bbcb328a4b405b30d45f5f3d
parentc8945d51613450c19e0898b1b3056c90f4929179
ocaml/xenctrl: Fix stub_xc_readconsolering()

The Ocaml stub to retrieve the hypervisor console ring had a few problems.

 * A single 32k buffer would truncate a large console ring.
 * The buffer was static and not under the protection of the Ocaml GC lock so
   could be clobbered by concurrent accesses.
 * Embedded NUL characters would cause caml_copy_string() (which is strlen()
   based) to truncate the buffer.

The function is rewritten from scratch, using the same algorithm as the python
stubs, but uses the protection of the Ocaml GC lock to maintain a static
running total of the ring size, to avoid redundant realloc()ing in future
calls.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Dave Scott <dave.scott@eu.citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/ocaml/libs/xc/xenctrl_stubs.c